//
//  AXAppDelegate+Config.m
//  MiaoCircle
//
//  Created by acgera on 2018/4/10.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "AXAppDelegate+Config.h"
#import "MHH5Links.h"
#import "MHRedEnvelopeConfig.h"
@implementation AXAppDelegate (Config)
+ (void)configureKeyboardManager {
    IQKeyboardManager.sharedManager.enable = YES;
    IQKeyboardManager.sharedManager.enableAutoToolbar = NO;
    IQKeyboardManager.sharedManager.shouldResignOnTouchOutside = YES;
}

+(void) configThirdPartShareLogin
{
    [OpenShare connectWeixinWithAppId:MHWECHATAPPID];
}


+(void) configControlAppApearance
{
  UITextField *textField =   [UITextField appearance];
    textField.returnKeyType = UIReturnKeyDone;
    UITextView *textView =   [UITextView appearance];
    textView.returnKeyType = UIReturnKeyDone;
}

-(void) getH5LinkList
{
    
    self.fetchH5Command  = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
        void (^doNext)(NSArray *) = ^(NSArray *links){
            YYCache *cache=[YYCache cacheWithName:MHCacheGlobleKey];
            [cache setObject:links forKey:MHH5LinksKey];
        };
       
        return [[[[MHHTTPService sharedInstance] getH5LinkList] mh_parsedResults] doNext:doNext];
    }];

}

-(void) getRedPacketConfig
{
    @weakify(self);
    [[[[MHHTTPService sharedInstance] getRedEnvelopeConfig] mh_parsedResults] subscribeNext:^(MHRedEnvelopeConfig *config) {
//        @strongify(self);
        YYCache *cache=[YYCache cacheWithName:MHCacheGlobleKey];
        [cache setObject:config forKey:MHRedPacketConfig];
    }];
}

-(void) getIllegalList
{
    self.fetchIllegalList  = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
        void (^doNext)(NSArray *) = ^(NSArray *illegalList){
            YYCache *cache=[YYCache cacheWithName:MHCacheGlobleKey];
            [cache setObject:illegalList forKey:MHIllegalList];
        };
        return [[[[MHHTTPService sharedInstance] getIllegalList] mh_parsedResults] doNext:doNext];
    }];
}
@end
